home *** CD-ROM | disk | FTP | other *** search
-
- #include "CTestDict.h"
- #include "CPascalString.h"
- #include "TBUtilities.h"
-
- /* map and compare procs for dictionary */
-
- uInt32 MapKey( void *key); /* map string to unsigned long */
- Boolean CompareKeys( void *key1, void *key2); /* compare two keys */
-
- /********************************************************************/
- Boolean CTestDict::ITestDict( void )
- {
- CDictionary::IDictionary( sizeof(Str20), MapKey, CompareKeys, 0);
-
- } /* CTestDict::ITestDict */
- /********************************************************************/
-
- /* map and compare procs for dictionary */
-
- uInt32 MapKey( void *key) /* map string to unsigned long */
- {
- Str20 copy;
- register unsigned char *s;
- register uInt32 sum = 1;
- register Int16 i, triplets;
- register unsigned short ch;
- Int16 length;
-
- pStrCopy( key, copy);
- UprString( copy, FALSE);
- s = copy;
- length = *s++;
- triplets = length / 3;
- for (i = 0; i < triplets; i++)
- {
- sum *= *s++;
- ch = *s++;
- sum *= ch << 1;
- ch = *s++;
- sum *= ch << 2;
- }
- for (i = triplets * 3; i < length; i++)
- sum *= *s++;
-
- sum >>= 8;
-
- return sum;
-
- }
- Boolean CompareKeys( void *key1, void *key2) /* compare two keys */
- {
- return EqualString( key1, key2, FALSE, FALSE);
- }